<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>


<script>

    // 用了 var 声明变量, 返回值就是 The Window
    var theWindow = 'The Window';
    var obj = {
        theWindow: 'My Object',
        getNameFunc: function () {
            return function () {
                return this.theWindow;
            }
        }
    };

    console.log(obj.getNameFunc()())     // The Window

    // 类似于
    // var nameFunc = obj.getNameFunc();
    // nameFunc();

    var theWindow02 = 'The Window';
    var obj02 = {
        theWindow02: 'My Object',
        // getNameFunc 是一个闭包函数
        getNameFunc: function () {
            var that = this;
            return function () {
                return that.theWindow02;
            }
        }
    };
    console.log(obj02.getNameFunc()())
    // 类似于
    // var func = obj02.getNameFunc();
    // var func = function () {
    //     return that.name;
    // }
    // func();

</script>
</body>
</html>
